// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from "vue";
import App from "./App";
import router from "./router";
import ElementUI from "element-ui";
import "element-ui/lib/theme-default/index.css";
import NProgress from "nprogress";
import "nprogress/nprogress.css";
// import VueParticles from "vue-particles";  //离子动画 IE 不支持
import * as filters from "./filter";
import store from "./store";

//兼容IE8 9 10 11
import "babel-polyfill";

//全局引入axios
import axios from "axios";
axios.defaults.withCredentials = true;
Vue.prototype.$http = axios;

// 响应时拦截
// const jm = {};
// jm.isJson = function(obj) {
//   var isjson =
//     typeof obj == "object" &&
//     Object.prototype.toString.call(obj).toLowerCase() == "[object object]" &&
//     !obj.length;
//   return isjson;
// };

Vue.use(ElementUI);
// Vue.use(VueParticles);
Vue.config.productionTip = false;

Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key]);
});
router.beforeEach((to, from, next) => {
  NProgress.start();
  next();
});

router.afterEach((to, from, next) => {
  NProgress.done();
});
/* eslint-disable no-new */
new Vue({
  el: "#app",
  router,
  store,
  template: "<App/>",
  components: { App }
});
